package puzzle.hashikake.solver;

import puzzle.common.data.HatanException;
import puzzle.common.solver.BoardRule;
import puzzle.hashikake.data.HashiState;
import puzzle.hashikake.data.HashikakeBoard;

/**
 * 1と1が対面していたらその間に橋はない、というルール。
 */
class OneOneRule implements BoardRule<HashikakeBoard> {

	public boolean apply(HashikakeBoard b) throws HatanException {
		boolean isChanged = false;
		for (HashiState s : b.getHashiStates()) {
			if (s.def.car.n == 1 && s.def.cdr.n == 1) {
				isChanged |= s.setNumber(0);
			}
		}
		return isChanged;
	}

}
